<?php


namespace app\controllers;


use app\entity\ActTypeEntity;
use app\models\UserDto;
use app\service\UserService;

class UserInfoController extends BaseJsonController
{
    /**
     * @param $req
     * @param $userInfo UserDto
     * @return \app\models\response\RespLogin|mixed
     * @throws \app\exception\OaException
     */
    public function doService($req,$userInfo)
    {
        $service  = new UserService();
        $userEntity = $service->findById($userInfo->getUserId());



        /**@var $actEntity ActTypeEntity*/
        $actEntity = ActTypeEntity::find()->where(["id"=>$userEntity->shop->scheme_type,"del_flag"=>0])->one();
        $schemeType = "";
        if ($actEntity) {
            $schemeType = $actEntity->getName();
        }
        return [
            "shopName"=>$userEntity->shop->shop_name,
            "connectName"=>$userEntity->getConnectName(),
            "connectPhone"=>$userEntity->getConnectPhone(),
            "connectAddress"=>$userEntity->shop->connect_address,
            "province"=>$userEntity->shop->province,
            "city"=>$userEntity->shop->city,
            "district"=>$userEntity->shop->district,
            "schemeType"=>$schemeType
        ];

    }

    public function needLogin(){
        return true;
    }
}